package com.geekaca.iobuffer;

import java.io.*;
import java.util.Properties;

public class TestProperties {
    public static void main(String[] args) {

        testReader();
    }

    public static void testWriter() {
        /**
         * 了解Properties类用法
         */

        Properties properties = new Properties();
        properties.setProperty("admin", "5656565");
        properties.setProperty("company", "geekaca");

        try {
            properties.store((new FileWriter("studyIOBuffer\\user.properties")), "这是一条文件注释");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void testReader()  {
        Properties properties = new Properties();
        try {
            properties.load(new FileReader("studyIOBuffer\\user.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        String admin = properties.getProperty("admin");
        String company = properties.getProperty("company");
        System.out.println(admin + " " + company);
    }
}
